From e588d94efc71b5f82731dddc2a721a7f36546dad Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Tue, 12 Jun 2007 15:16:03 -0600 Subject: [PATCH] [IA64] Use virtualized psr in vcpu context instead of real psr. Signed-off-by: Tristan Gingold --- tools/libxc/ia64/xc_ia64_hvm_build.c | 6 +++ tools/libxc/ia64/xc_ia64_linux_restore.c | 12 +---- tools/libxc/xc_dom_ia64.c | 6 ++- xen/arch/ia64/vmx/vlsapic.c | 5 +- xen/arch/ia64/xen/domain.c | 63 +++++++++++------------- xen/arch/ia64/xen/hypercall.c | 6 +-- xen/arch/ia64/xen/vcpu.c | 2 - 7 files changed, 42 insertions(+), 58 deletions(-) diff --git a/tools/libxc/ia64/xc_ia64_hvm_build.c b/tools/libxc/ia64/xc_ia64_hvm_build.c index 690d12c8f9..0c0a9e36e0 100644 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c @@ -1,3 +1,4 @@ +#include #include "xg_private.h" #include "xenguest.h" #include "xc_private.h" @@ -1083,6 +1084,11 @@ xc_hvm_build(int xc_handle, uint32_t domid, int memsize, const char *image_name) free(image); ctxt->regs.ip = 0x80000000ffffffb0UL; + ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); + ctxt->regs.cr.isr = 1UL << 63; + ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_BN; + ctxt->regs.cr.dcr = 0; + ctxt->regs.cr.pta = 15 << 2; memset(&launch_domctl, 0, sizeof(launch_domctl)); diff --git a/tools/libxc/ia64/xc_ia64_linux_restore.c b/tools/libxc/ia64/xc_ia64_linux_restore.c index 509533904c..26a39715c0 100644 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c @@ -227,17 +227,7 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, fprintf(stderr, "ip=%016lx, b0=%016lx\n", ctxt.regs.ip, ctxt.regs.b[0]); - /* First to initialize. */ - domctl.cmd = XEN_DOMCTL_setvcpucontext; - domctl.domain = (domid_t)dom; - domctl.u.vcpucontext.vcpu = 0; - set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt); - if (xc_domctl(xc_handle, &domctl) != 0) { - ERROR("Couldn't set vcpu context"); - goto out; - } - - /* Second to set registers... */ + /* Initialize and set registers. */ ctxt.flags = VGCF_EXTRA_REGS; domctl.cmd = XEN_DOMCTL_setvcpucontext; domctl.domain = (domid_t)dom; diff --git a/tools/libxc/xc_dom_ia64.c b/tools/libxc/xc_dom_ia64.c index 18b129fc11..7c7eac0eb2 100644 --- a/tools/libxc/xc_dom_ia64.c +++ b/tools/libxc/xc_dom_ia64.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -106,9 +107,10 @@ static int vcpu_ia64(struct xc_dom_image *dom, void *ptr) memset(ctxt, 0, sizeof(*ctxt)); ctxt->flags = 0; - ctxt->regs.psr = 0; /* all necessary bits filled by hypervisor */ + /* PSR is set according to SAL 3.2.4: AC, IC and BN are set. */ + ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN; ctxt->regs.ip = dom->parms.virt_entry; - ctxt->regs.cfm = (uint64_t) 1 << 63; + ctxt->regs.cfm = 1UL << 63; #ifdef __ia64__ /* FIXME */ ctxt->regs.ar.fpsr = xc_ia64_fpsr_default(); #endif diff --git a/xen/arch/ia64/vmx/vlsapic.c b/xen/arch/ia64/vmx/vlsapic.c index b262a809c4..10e42a7f75 100644 --- a/xen/arch/ia64/vmx/vlsapic.c +++ b/xen/arch/ia64/vmx/vlsapic.c @@ -696,11 +696,8 @@ static void vlsapic_write_ipi(VCPU *vcpu, uint64_t addr, uint64_t value) test_bit(_VPF_down, &targ->pause_flags)) { struct pt_regs *targ_regs = vcpu_regs(targ); - struct vcpu_guest_context c; - memset (&c, 0, sizeof(c)); - - if (arch_set_info_guest(targ, &c) != 0) { + if (arch_set_info_guest(targ, NULL) != 0) { printk("arch_boot_vcpu: failure\n"); return; } diff --git a/xen/arch/ia64/xen/domain.c b/xen/arch/ia64/xen/domain.c index b9b86adc44..1661e279af 100644 --- a/xen/arch/ia64/xen/domain.c +++ b/xen/arch/ia64/xen/domain.c @@ -622,12 +622,10 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) c.nat->regs.r[10] = uregs->r10; c.nat->regs.r[11] = uregs->r11; - if (is_hvm) { - c.nat->regs.psr = vmx_vcpu_get_psr (v); - } else { - /* FIXME: get the vpsr. */ - c.nat->regs.psr = uregs->cr_ipsr; - } + if (is_hvm) + c.nat->regs.psr = vmx_vcpu_get_psr(v); + else + c.nat->regs.psr = vcpu_get_psr(v); c.nat->regs.ip = uregs->cr_iip; c.nat->regs.cfm = uregs->cr_ifs; @@ -717,6 +715,26 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c) struct domain *d = v->domain; int rc; + /* Finish vcpu initialization. */ + if (!v->is_initialised) { + if (d->arch.is_vti) + rc = vmx_final_setup_guest(v); + else + rc = vcpu_late_initialise(v); + if (rc != 0) + return rc; + + vcpu_init_regs(v); + + v->is_initialised = 1; + /* Auto-online VCPU0 when it is initialised. */ + if (v->vcpu_id == 0) + clear_bit(_VPF_down, &v->pause_flags); + } + + if (c.nat == NULL) + return 0; + uregs->b6 = c.nat->regs.b[6]; uregs->b7 = c.nat->regs.b[7]; @@ -727,8 +745,11 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c) uregs->r9 = c.nat->regs.r[9]; uregs->r10 = c.nat->regs.r[10]; uregs->r11 = c.nat->regs.r[11]; - - uregs->cr_ipsr = c.nat->regs.psr; + + if (!d->arch.is_vti) + vcpu_set_psr(v, c.nat->regs.psr); + else + vmx_vcpu_set_psr(v, c.nat->regs.psr); uregs->cr_iip = c.nat->regs.ip; uregs->cr_ifs = c.nat->regs.cfm; @@ -813,32 +834,6 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c) v->arch.iva = c.nat->regs.cr.iva; } - if (v->is_initialised) - return 0; - - if (d->arch.is_vti) { - rc = vmx_final_setup_guest(v); - if (rc != 0) - return rc; - } else { - rc = vcpu_late_initialise(v); - if (rc != 0) - return rc; - VCPU(v, interrupt_mask_addr) = - (unsigned char *) d->arch.shared_info_va + - INT_ENABLE_OFFSET(v); - } - - /* This overrides some registers. */ - vcpu_init_regs(v); - - if (!v->is_initialised) { - v->is_initialised = 1; - /* Auto-online VCPU0 when it is initialised. */ - if (v->vcpu_id == 0) - clear_bit(_VPF_down, &v->pause_flags); - } - return 0; } diff --git a/xen/arch/ia64/xen/hypercall.c b/xen/arch/ia64/xen/hypercall.c index e43a9ed5e9..dffc95e5f6 100644 --- a/xen/arch/ia64/xen/hypercall.c +++ b/xen/arch/ia64/xen/hypercall.c @@ -86,11 +86,7 @@ fw_hypercall_ipi (struct pt_regs *regs) /* First start: initialize vpcu. */ if (!targ->is_initialised) { - struct vcpu_guest_context c; - - memset (&c, 0, sizeof (c)); - - if (arch_set_info_guest (targ, &c) != 0) { + if (arch_set_info_guest (targ, NULL) != 0) { printk ("arch_boot_vcpu: failure\n"); return; } diff --git a/xen/arch/ia64/xen/vcpu.c b/xen/arch/ia64/xen/vcpu.c index 4a6227515f..120072d4b8 100644 --- a/xen/arch/ia64/xen/vcpu.c +++ b/xen/arch/ia64/xen/vcpu.c @@ -182,8 +182,6 @@ void vcpu_init_regs(struct vcpu *v) INT_ENABLE_OFFSET(v); VCPU(v, itv) = (1 << 16); /* timer vector masked */ - /* SAL specification 3.2.4 */ - VCPU(v, vpsr) = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN; v->vcpu_info->evtchn_upcall_pending = 0; v->vcpu_info->evtchn_upcall_mask = -1; } -- 2.30.2